import { request } from '@/utils/request';

// 中控报检
export const formList = (diff: string, query?: any) => {
  return request({
    url: `/pm/${diff}/page`,
    method: 'GET',
    query,
  });
};

export const formSave = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}`,
    method: 'POST',
    data,
  });
};

export const formUpdate = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}`,
    method: 'PUT',
    data,
  });
};

export const formInfo = (diff: string, id: string) => {
  return request({
    url: `/pm/${diff}/${id}`,
    method: 'GET',
  });
};

export const formSubmit = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/submitProcess`,
    method: 'POST',
    data,
  });
};

export const revokeProcess = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/revoke`,
    method: 'POST',
    data,
  });
};

export const formComplete = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/complete`,
    method: 'POST',
    data,
  });
};

export const formRevive = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/revive`,
    method: 'POST',
    data,
  });
};

// 根据任务生成报检单
export const formInfoByTask = (id: string, version: string) => {
  return request({
    url: `/pm/rdTask/getInfo/${id}/${version}`,
    method: 'GET',
  });
};
// 根据试验记录生成报检单
export const ccFormInfoByExperimentRecord = (id: string, type: number) => {
  return request({
    url: `/pm/experimentRecord/getInfo/${id}/${type}`,
    method: 'GET',
  });
};

export const analysisList = (query?: any) => {
  return request({
    url: '/pm/baseAnalysis/page',
    method: 'GET',
    query,
  });
};
export const fetchAssayerList = (query?: any) => {
  return request({
    url: '/admin/hrPerson/page',
    method: 'GET',
    query,
  });
};

/**
 *检验报告
 * * */
export const reportList = (diff: string, query?: any) => {
  return request({
    url: `/pm/${diff}/page`,
    method: 'GET',
    query,
  });
};

export const reportInfo = (diff: string, query?: any) => {
  return request({
    url: `/pm/${diff}/getInfo`,
    method: 'GET',
    query,
  });
};

export const retInfoBarCode = (diff: string, code: string) => {
  return request({
    url: `/pm/${diff}/getInfoBarCode/${code}`,
    method: 'GET',
  });
};

export const reportSave = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}`,
    method: 'POST',
    data,
  });
};

export const reportUpdate = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}`,
    method: 'PUT',
    data,
  });
};

export const reportSubmit = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/submitProcess`,
    method: 'POST',
    data,
  });
};

export const reportRevoke = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/revoke`,
    method: 'POST',
    data,
  });
};

export const reportRevive = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/revive`,
    method: 'POST',
    data,
  });
};

export const reportComplete = (diff: string, data: any) => {
  return request({
    url: `/pm/${diff}/complete`,
    method: 'POST',
    data,
  });
};

export const getInfoBarCode = (code: string) => {
  const type = code.indexOf('TA') === 0 ? 'qcMiddleCheck' : 'qcExoticCheck';
  return request({
    url: `/pm/${type}/getInfoBarCode/${code}`,
    method: 'GET',
  });
};

export const ccRetInfoBarCode = (code: string) => {
  return request({
    url: `/pm/qcMiddleCheck/getInfoBarCode/${code}`,
    method: 'GET',
  });
};

export const getFormInfoVersion = (query: any) => {
  return request({
    url: `/pm/rdSampleAnalysis/getSampleByTaskId`,
    method: 'GET',
    query,
  });
};

export const getAssayers = (code?: string) => {
  return request({
    url: `/pm/baseEquipment/getUserCodeByEquipmentCode/${code}`,
    method: 'GET',
  });
};

export const pageByTask = (query: Object) => {
  return request({
    url: `/pm/qcExoticCheck/pageByTask`,
    method: 'GET',
    query,
  });
};
